package com.gitee.wsl.struct.either.ext

import arrow.core.Either
import arrow.core.flatMap

/**
 * Performs an effect over the right side of the value but maps the original value back into
 * the Either.  This is useful for mixing with validation functions.
 */
inline fun <A, B, C> Either<A, B>.flatTap(f: (B) -> Either<A, C>): Either<A, B> = this.flatMap { b ->
    f(b).map { b }
}